home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-reatim.ads < prev    next >
Text File  |  1994-05-19  |  6KB  |  159 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                      S Y S T E M . R E A L _ T I M E                     --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.8 $                             --
  10. --                                                                          --
  11. --           Copyright (c) 1991,1992,1993, FSU, All Rights Reserved         --
  12. --                                                                          --
  13. --  GNARL is free software; you can redistribute it and/or modify it  under --
  14. --  terms  of  the  GNU  Library General Public License as published by the --
  15. --  Free Software Foundation; either version 2,  or  (at  your  option) any --
  16. --  later  version.   GNARL is distributed in the hope that it will be use- --
  17. --  ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
  18. --  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. --  eral Library Public License for more details.  You should have received --
  20. --  a  copy of the GNU Library General Public License along with GNARL; see --
  21. --  file COPYING. If not, write to the Free Software Foundation,  675  Mass --
  22. --  Ave, Cambridge, MA 02139, USA.                                          --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26.  
  27. with System.Task_Clock;
  28.  
  29. with System.Task_Clock.Machine_Specifics;
  30.  
  31. with System.Tasking.Protected_Objects;
  32.  
  33. package System.Real_Time is
  34.  
  35. --  The following part should be private. For now, they are public
  36. --  (compiler error) ???
  37.  
  38. --  private
  39.  
  40.    type Time is new Task_Clock.Stimespec;
  41.  
  42.    Time_First : constant Time := Time (Task_Clock.Stimespec_First);
  43.  
  44.    Time_Last :  constant Time := Time (Task_Clock.Stimespec_Last);
  45.  
  46.    type Time_Span is new Task_Clock.Stimespec;
  47.  
  48.    Time_Span_First : constant Time_Span :=
  49.      Time_Span (Task_Clock.Stimespec_First);
  50.  
  51.    Time_Span_Last :  constant Time_Span :=
  52.      Time_Span (Task_Clock.Stimespec_Last);
  53.  
  54.    Time_Span_Zero :  constant Time_Span :=
  55.      Time_Span (Task_Clock.Stimespec_Zero);
  56.  
  57.    Time_Span_Unit :  constant Time_Span :=
  58.      Time_Span (Task_Clock.Stimespec_Unit);
  59.  
  60.    Tick :           constant Time_Span :=
  61.      Time_Span (Task_Clock.Machine_Specifics.Stimespec_Ticks);
  62.  
  63. --   Following has to be re-activated once the private part is used. ???
  64.  
  65. --   type Time is private;
  66. --   Time_First : constant Time;
  67. --   Time_Last :  constant Time;
  68.  
  69. --   type Time_Span is private;
  70. --   Time_Span_First : constant Time_Span;
  71. --   Time_Span_Last :  constant Time_Span;
  72. --   Time_Span_Zero :  constant Time_Span;
  73. --   Time_Span_Unit :  constant Time_Span;
  74. --   Ticks :           constant Time_Span;
  75.  
  76.    Time_Unit : constant := 10#1.0#E-9;
  77.  
  78.    function Clock return Time;
  79.  
  80.    function "+"  (Left : Time;      Right : Time_Span) return Time;
  81.    function "+"  (Left : Time_Span; Right : Time)      return Time;
  82.    function "-"  (Left : Time;      Right : Time_Span) return Time;
  83.    function "-"  (Left,             Right : Time)      return Time_Span;
  84.  
  85.    function "<"  (Left, Right : Time) return Boolean;
  86.    function "<=" (Left, Right : Time) return Boolean;
  87.    function ">"  (Left, Right : Time) return Boolean;
  88.    function ">=" (Left, Right : Time) return Boolean;
  89.  
  90.    function "+"  (Left, Right : Time_Span) return Time_Span;
  91.    function "-"  (Left, Right : Time_Span) return Time_Span;
  92.    function "-"  (Right : Time_Span) return Time_Span;
  93.  
  94.    function "/"  (Left, Right : Time_Span) return Integer;
  95.  
  96.    function "/"  (Left : Time_Span; Right : Integer) return Time_Span;
  97.    function "*"  (Left : Time_Span; Right : Integer) return Time_Span;
  98.    function "*"  (Left : Integer; Right : Time_Span) return Time_Span;
  99.  
  100.    function "<"  (Left, Right : Time_Span) return Boolean;
  101.    function "<=" (Left, Right : Time_Span) return Boolean;
  102.    function ">"  (Left, Right : Time_Span) return Boolean;
  103.    function ">=" (Left, Right : Time_Span) return Boolean;
  104.  
  105.    function "abs" (Right : Time_Span) return Time_Span;
  106.  
  107.    function To_Duration (FD : Time_Span) return Duration;
  108.    function To_Time_Span (D : Duration) return Time_Span;
  109.  
  110.    function Nanoseconds  (NS : integer) return Time_Span;
  111.    function Microseconds (US : integer) return Time_Span;
  112.    function Milliseconds (MS : integer) return Time_Span;
  113.  
  114. --  Hand translation code will be provided here for now.
  115. --  Until the GNAT compiler can accomodate the protected objects. ???
  116.  
  117.    package Delay_Object is
  118.       Object : aliased Tasking.Protection (Num_Entries => 1);
  119.  
  120.       type Params is record
  121.          Param : Time_Span;
  122.       end record;
  123.  
  124.       procedure Service_Entries (Pending_Serviced : out Boolean);
  125.    end Delay_Object;
  126.  
  127.    type Seconds is new integer range -integer'Last .. integer'Last;
  128.    --  Seconds is signed entity
  129.  
  130.    procedure Split (T : Time; S : out Seconds; D : out Time_Span);
  131.    function Time_Of (S : Seconds; D : Time_Span) return Time;
  132.  
  133. --  private
  134.  
  135. --   type Time is new Task_Clock.Stimespec;
  136.  
  137. --   Time_First : constant Time := Time (Task_Clock.Stimespec_First);
  138.  
  139. --   Time_Last :  constant Time := Time (Task_Clock.Stimespec_Last);
  140.  
  141. --   type Time_Span is new Task_Clock.Stimespec;
  142.  
  143. --   Time_Span_First : constant Time_Span :=
  144. --     Time_Span (Task_Clock.Stimespec_First);
  145.  
  146. --   Time_Span_Last :  constant Time_Span :=
  147. --     Time_Span (Task_Clock.Stimespec_Last);
  148.  
  149. --   Time_Span_Zero :  constant Time_Span :=
  150. --     Time_Span (Task_Clock.Stimespec_Zero);
  151.  
  152. --   Time_Span_Unit :  constant Time_Span :=
  153. --     Time_Span (Task_Clock.Stimespec_Unit);
  154.  
  155. --   Ticks :           constant Time_Span :=
  156. --     Time_Span (Task_Clock.Stimespec_Ticks);
  157.  
  158. end System.Real_Time;
  159.